<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page import="java.util.List"%>
<%@page import="database.*"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/Project1/layui-v2.6.13/layui/css/layui.css"/>
		<style>
			#limitPage button{
				margin: 0;
			}
		</style>
		<script type="text/javascript" src="/Project1/layui-v2.6.13/layui/layui.js"></script>
	</head>

	<body>
		<div style="padding: 20px;">
			<button class="layui-btn" onclick="openLayer2()">添加</button>		
			<div>
				<table class="layui-table">
					<colgroup>
						<col width="100">
						<col width="400">	
						<col width="500">
						<col>
					</colgroup>
					<thead>
						<tr>
							<th>专业ID</th>
							<th>专业名称</th>
							<th>所属学院</th>
							<th>操作</th>
						</tr> 
					</thead>
					<tbody>
						<c:forEach items="${ma }" var="obj">
						<tr>
							<td>${obj.id }</td>
							<td>${obj.name }</td>
							<td>
							<c:forEach items="${colist}" var="obj2">
									<c:if test="${obj2.id eq obj.c_id}">${obj2.name}</c:if>
							</c:forEach>
							</td>
							<td>
								<button class="layui-btn" onclick="openLayer(${obj.id},${obj.c_id })">更新</button>
							</td>
						</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
			<div id="limitPage" align="center">
				<button class="layui-btn layui-btn-sm layui-btn-primary layui-border-green" onclick="jump(1,${pagenum})">首页</button>
				<button class="layui-btn layui-btn-sm" onclick="jump(${page-1},${pagenum})">上一页</button>
				<span class="layui-font-16">${page }/${pagenum }页</span>
				<button class="layui-btn layui-btn-sm" onclick="jump(${page+1},${pagenum})">下一页</button>
				<button class="layui-btn layui-btn-sm layui-btn-primary layui-border-green" onclick="jump(${pagenum},${pagenum})">尾页</button>
			</div>
		</div>
	</body>
	<script>
		function jump(page,pagenum){
			if(page<1) page=1;
			if(page>pagenum) page=pagenum;
			window.location.href = "m?method=topage&page="+page+"&pagenum="+pagenum;
		}	
	
		layui.use("layer", function(){
			var layer = layui.layer;
		});
		
		function openLayer(id,cid){
			layer.open({
			  type: 2, 
			  area: ['650px', '500px'],
			  content: 'page/majorup.jsp?id='+id+'&cid='+cid,
			  end: function(){
				  location.reload();
			  }
			});
		}
		function openLayer2(){
			layer.open({
			  type: 2, 
			  area: ['650px', '500px'],
			  content: 'page/majorin.jsp',
			  end: function(){
				  location.reload();
			  }
			});
		}
	</script>
</html>










